<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="kokonut.shop.size.Size" %>
<%@ page import="kokonut.shop.color.Color" %>
<%@ page import="kokonut.shop.product.TShirtModel" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="ProductPersistence" class="persistence.ProductPersistence" scope="request" />
<jsp:useBean id="CartController" class="kokonut.shop.cart.CartController" scope="session" />
<jsp:useBean id="LanguageSelector" class="resources.LanguageSelector" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css" media="all">@import
		"pageStyle.css";</style>
		<style type="text/css" media="all">@import
		"shopStyle.css";</style>
		<link  href="//fonts.googleapis.com/css?family=Raleway:100" rel="stylesheet" type="text/css" >
		<link  href="//fonts.googleapis.com/css?family=Inconsolata:regular" rel="stylesheet" type="text/css" >
		<link  href="//fonts.googleapis.com/css?family=Droid+Sans:regular,bold" rel="stylesheet" type="text/css" >
        <title>Kokonut Web :: Store</title>
    </head>
    <body>
        <fmt:setLocale value="<%=LanguageSelector.getLocaleName()%>" scope="session" />
        <fmt:bundle basename="ApplicationResources">
        <div id="regionSwitcher">
                <fmt:setLocale value="<%=LanguageSelector.getLocaleName()%>" scope="session" />
                <div id="languages">
                	<ul>
                	<li id="euskara"><a href="/selectLocale?locale=eu_ES&url=shop"><b>euskara</b></a></li>
                	<li id="castellano"><a href="/selectLocale?locale=es_ES&url=shop"><b>castellano</b></a></li> 
                	<li id="english"><a href="/selectLocale?locale=en_UK&url=shop"><b>english</b></a></li>
                	</ul>
                </div>
            </div>
            <div id="pageContainer">
            	<div id="menu">
                    <ul>
                        <li id="home"><a href="/"><b><fmt:message key="home" /></b></a></li>
                        <li id="store"><a href="/shop"><b><fmt:message key="shop" /></b></a></li>
                        <li id="blog"><a href="/blog"><b><fmt:message key="blog" /></b></a></li>
                        <li id="contact"><a href="/contact"><b><fmt:message key="contact" /></b></a></li>
                    </ul>
                </div>
                <div id="header">
                    <h1>Kokonut Web</h1>
                    <div id="cartPlace"><a href="/cart">
	                    <img src="images/Cart.png" alt="cart image">
	                	<% if(CartController.getNumberOfProducts()==0)
	                	   {
	                	%>
	                	<fmt:message key="emptyCart" />
	                	<%}
	                	else
	                	{
	                	%>
	                	<fmt:message key="cart" />: <%=CartController.getNumberOfProducts()%> <fmt:message key="products" />
	                	<%}
	                	%>
	                	<br/>
	                	<fmt:message key="totalPrice" />: <%=CartController.getTotalPrice()%> €
	                	</a>
	                </div>
                </div>
                <div class="content">

                    <div id="shopSpace">

                        <%
                            List<TShirtModel> productList = ProductPersistence.loadModelList();
                            if (productList.isEmpty()) {
                        %>
                        <p>No products saved</p>
                        <%
                        	}
                        	else
                        	{
                            	for (TShirtModel t : productList) {
                        %>
                        <div id="product">
                            <h3><%=t.getName()%></h3>
                            <div id="productImage"><a href="/product?ref=<%=t.getRef()%>">
                                    <img alt="" border="0" src="<%="/serve?blob-key=" + t.getModelImages().get(0).getImageKey() %>"/></a></div>
                        </div>
                        <%
                                        }
                                    }
                        %>
                    </div>
                </div>
                <div id="footer">
                	<div id="altNav"><a href="/"><fmt:message key="home" /></a> | <a href="/shop"><fmt:message key="shop" /></a> | <a href="/blog"><fmt:message key="blog" /></a> | <a href="/contact"><fmt:message key="contact" /></a></div>
                	<div id="communicator"> Tuenti | Facebook | Twitter</div>
                	<div id="admin"><a href="/admin">Admin</a></div>
                </div>
            </div>
        </fmt:bundle>
    </body>
</html>